#
# Copyright (C) 2007-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=qpdf_lede
PKG_VERSION:=11.9.1
PKG_RELEASE:=1

PKG_SOURCE_NAME:=qpdf
PKG_SOURCE:=$(PKG_SOURCE_NAME)-$(PKG_VERSION).tar.gz
##PKG_SOURCE_URL:=https://github.com/qpdf/qpdf/archive/refs/tags/v$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/qpdf/qpdf/tar.gz/refs/tags/v$(PKG_VERSION)
PKG_HASH:=98d509e29def377d90ff4a34e48e8e20865600342006bff53e489f689bbbb15d

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_NAME)-$(PKG_VERSION)
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_SOURCE_NAME)-$(PKG_VERSION)

CMAKE_INSTALL:=1

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/qpdf_lede
  SECTION:=utils
  CATEGORY:=Printing
  TITLE:=QPDF is a command-line program for transformations on PDF files.
  DEPENDS:= +libpcre2 +zlib +libstdcpp +libatomic +libopenssl +libgnutls +libjpeg-turbo
  URL:=http://qpdf.sourceforge.net/
  SUBMENU:=Utilities
endef

define Package/qpdf_lede/description
QPDF is a command-line program that does structural, content-preserving
transformations on PDF files. It could have been called something like pdf-to-pdf.
It also provides  many useful capabilities to developers of PDF-producing software
or for people who just want to look at the innards of a PDF file to learn more
about how they work.
endef

CMAKE_INSTALL:=1
CMAKE_BINARY_SUBDIR:=build

CMAKE_OPTIONS += \
	-DBUILD_DOC:BOOL=OFF

define Package/qpdf_lede/install
	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
	$(INSTALL_DIR) $(1)/usr/include
	$(CP) -r $(PKG_INSTALL_DIR)/usr/include/qpdf $(1)/usr/include/
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib
endef

$(eval $(call BuildPackage,qpdf_lede))
